﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using dahtd4ever.GameScreens;

namespace dahtd4ever
{
    public enum GameState
    {
        Menu,
        Play,
        Pause,
        GameOver,
        Levelauswahl
    }
    public class ScreenManager : DrawableGameComponent
    {
        public static GameState gameState = GameState.Menu;
        public static GameState lastState = GameState.Menu;
        public static Keyboard keyboard;
        public static Boolean newGame = false;
        Menu menuScreen;
        Pause pause;
        GameOver gameOver;
        GameScreen gScreen;
        Levelauswahl levelauswahl;
        
        public ScreenManager(Game1 game)
            : base(game)
        {
            menuScreen = new Menu(game);
            gScreen = new GameScreen(game);
            pause = new Pause(game);
            gameOver = new GameOver();
            keyboard = new Keyboard();
            levelauswahl = new Levelauswahl(game, gScreen);
        }

        public override void Update(GameTime gameTime)
        {
            keyboard.Update();

            switch (gameState)
            {
                case GameState.Menu:
                    menuScreen.Update(gameTime);
                    break;
                case GameState.Play:
                    if (newGame)
                    {
                        gScreen.newGame();
                    }
                    gScreen.Update(gameTime);
                    newGame = false;
                    break;
                case GameState.Pause:
                    pause.Update(gameTime);
                    break;
                case GameState.GameOver:
                    gameOver.Update(gameTime);
                    break;
                case GameState.Levelauswahl:
                    levelauswahl.Update(gameTime);
                    break;
            }
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            switch (gameState)
            {
                case GameState.Menu:
                    menuScreen.Draw();
                    break;
                case GameState.Play:
                    gScreen.Draw();
                    break;
                case GameState.Pause:
                    pause.Draw();
                    break;
                case GameState.GameOver:
                    gameOver.Draw();
                    break;
                case GameState.Levelauswahl:
                    levelauswahl.Draw();
                    break;
            }
            base.Draw(gameTime);
        }
    }
}
